//
//  QOilStandardCell.m
//  QoilPublic
//
//  Created by 杨凯 on 2017/4/25.
//  Copyright © 2017年 杨凯. All rights reserved.
//

#import "QOilStandardCell.h"
#import "QStandardModel.h"
@interface QOilStandardCell ()
@property (weak, nonatomic) IBOutlet UIButton *standardBtn;
@property (weak, nonatomic) IBOutlet UIButton *standardBtn1;
@property (weak, nonatomic) IBOutlet UIButton *standardBtn2;

@end
@implementation QOilStandardCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _standardBtn.tag = 1;
    _standardBtn1.tag = 2;
    _standardBtn2.tag = 3;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}
- (void)setArr:(NSMutableArray *)arr{
    _arr = arr;
    
    if (_arr.count == 1) {
        _standardBtn.hidden = NO;
        _standardBtn1.hidden = YES;
        _standardBtn2.hidden = YES;
        [self button];
    }else if (_arr.count == 2){
        _standardBtn.hidden = NO;
        _standardBtn1.hidden = NO;
        _standardBtn2.hidden = YES;

        [self button];
        [self button1];

    }else if (_arr.count == 3){
        _standardBtn.hidden = NO;
        _standardBtn1.hidden = NO;
        _standardBtn2.hidden = NO;
        [self button];
        [self button1];
        [self button2];

    }else if (_arr.count == 0){
        _standardBtn.hidden = YES;
        _standardBtn1.hidden = YES;
        _standardBtn2.hidden = YES;
    }
}
- (void)button{
    QStandardModel * model =[_arr objectAtIndex:0];
    if (model.select == YES) {
        [_standardBtn setTitle:model.oilType forState:0];
        [_standardBtn setBackgroundImage:[UIImage imageNamed:@"Standard_blue"] forState:0];
        [_standardBtn setTitleColor:[UIColor whiteColor] forState:0];
    }else if (model.select == NO){
        [_standardBtn setTitle:model.oilType forState:0];
        [_standardBtn setBackgroundImage:[UIImage imageNamed:@"Standard_white"] forState:0];
        [_standardBtn setTitleColor:[QColorUtility defaultDeepGrayColor] forState:0];
        
    }

}

- (void)button1{
    QStandardModel * model1 =[_arr objectAtIndex:1];
    if (model1.select == YES) {
        [_standardBtn1 setTitle:model1.oilType forState:0];
        [_standardBtn1 setBackgroundImage:[UIImage imageNamed:@"Standard_blue"] forState:0];
        [_standardBtn1 setTitleColor:[UIColor whiteColor] forState:0];
    }else if (model1.select == NO){
        [_standardBtn1 setTitle:model1.oilType forState:0];
        [_standardBtn1 setBackgroundImage:[UIImage imageNamed:@"Standard_white"] forState:0];
        [_standardBtn1 setTitleColor:[QColorUtility defaultDeepGrayColor] forState:0];
        
    }

}

- (void)button2{
    QStandardModel * model2 =[_arr objectAtIndex:2];
    if (model2.select == YES) {
        [_standardBtn2 setTitle:model2.oilType forState:0];
        [_standardBtn2 setBackgroundImage:[UIImage imageNamed:@"Standard_blue"] forState:0];
        [_standardBtn2 setTitleColor:[UIColor whiteColor] forState:0];
    }else if (model2.select == NO){
        [_standardBtn2 setTitle:model2.oilType forState:0];
        [_standardBtn2 setBackgroundImage:[UIImage imageNamed:@"Standard_white"] forState:0];
        [_standardBtn2 setTitleColor:[QColorUtility defaultDeepGrayColor] forState:0];
        
    }

}


- (IBAction)standardAction1:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(standardAction:)]) {
        [self.delegate standardAction:sender.tag];
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
